package cm.shit;
import java.util.Arrays;
import java.util.Comparator;

class StringLengthComparator implements Comparator<String> {
    @Override
    public int compare(String o1, String o2) {
        return o1.length() - o2.length();
    }
}
public class TestComparator {
    public static void main(String[] args) {
        String a = "aaa";
        String b = "bb";
        String c = "cccccc";
        String[] ss = new String[3];
        ss[0] = a;
        ss[1] = b;
        ss[2] = c;
        Arrays.sort(ss);
        // [aaa, bb, cccccc]
        System.out.println(Arrays.toString(ss));
        Arrays.sort(ss, new StringLengthComparator());
        // [bb, aaa, cccccc]
        System.out.println(Arrays.toString(ss));
    }
}
